package com.YHVision.qiuzhike.model.vo;

import cn.hutool.json.JSONUtil;
import com.YHVision.qiuzhike.model.entity.UserCompany;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户企业关联视图
 *
 * @author <a href="">YHVision-小y</a>
 * @from <a href="todo">爱编程学习圈</a>
 */
@Data
public class UserCompanyVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 用户 id
     */
    private Long userId;

    /**
     * 企业 id
     */
    private Long companyId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 创建用户信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param userCompanyVO
     * @return
     */
    public static UserCompany voToObj(UserCompanyVO userCompanyVO) {
        if (userCompanyVO == null) {
            return null;
        }
        UserCompany userCompany = new UserCompany();
        BeanUtils.copyProperties(userCompanyVO, userCompany);
        return userCompany;
    }

    /**
     * 对象转封装类
     *
     * @param userCompany
     * @return
     */
    public static UserCompanyVO objToVo(UserCompany userCompany) {
        if (userCompany == null) {
            return null;
        }
        UserCompanyVO userCompanyVO = new UserCompanyVO();
        BeanUtils.copyProperties(userCompany, userCompanyVO);
        return userCompanyVO;
    }
}
